/*
 * @Descripttion:
 * @version:
 * @Author: ChenXiang
 * @Date: 2021-05-12 22:46:40
 * @LastEditors: ChenXiang
 * @LastEditTime: 2021-08-13 16:02:01
 */
import React, { useState, useEffect } from "react";
import Button from "@/components/Button";

export default function App() {
  const [retry, setRetry] = useState(() => () => {});
  const callbackRef = React.useRef(() => alert("init"));
  const callback = callbackRef.current;

  const alert1 = () => {
    alert(1);
  };
  return (
    <div className="App">
      <Button
        btnType="danger"
        onClick={() => (callbackRef.current = () => alert("updated"))}
      >
        setCallback
      </Button>
      <Button onClick={callback}>call callback</Button>
      <Button
        onClick={() => {
          setRetry(() => {
            return 1;
          });
        }}
      >
        11111111
      </Button>
      <Button
        onClick={() => {
          setRetry(() => {
            return 2;
          });
        }}
      >
        222222
      </Button>
      <Button
        onClick={() => {
          console.log(retry);
        }}
      >
        2222
      </Button>
    </div>
  );
}
